function [dAeffBydLamba] = AeffDerivative(lambda_i, fVec, Params)
% 
% AEFFDERIVATE - compute the derivative of the effective amplitude
%     A_eff = C (theta, phi, psi, iota) A(f; M, eta) / dL
% with respect to the parameter lambda_i = {theta, phi, psi, iota, ...
%     log(M), log(eta), log(dL)}. 
% 
% usage: [dAeffBydLamba] = AeffDerivative(lambda_i, fVec, Params)
% 
% P. Ajith, 7 Aug 2009
% 
% $Id: AeffDerivative.m 59 2010-01-20 21:41:01Z anand.sengupta $

    setconstants

    M = Params.totalMass*MSOLAR_TIME;
    eta = Params.eta;
    dL = Params.dL*PARSEC_SEC*1e6;
    theta  = Params.theta;
    phi = Params.phi;
    psi = Params.psi;
    iota = Params.iota;
    Det = Params.Det;

    switch lambda_i 
        case 'M'
            dABydM = (5*sqrt(5*eta/6))/(12*M^(1/6)*pi^(2/3))*fVec.^(-7/6);
            C = CalcC(phi, theta, psi, iota, Det);
            dAeffBydM = (C/dL)*dABydM;
            dAeffBydLamba = M*dAeffBydM;        % returned derivative is with log(M)
        case 'eta'
            dABydEta = (sqrt(5/6)*M^(5/6))/(4*pi^(2/3)*sqrt(eta))*fVec.^(-7/6);
            C = CalcC(phi, theta, psi, iota, Det);
            dAeffBydEta = (C/dL)*dABydEta;
            dAeffBydLamba = eta*dAeffBydEta;    % returned derivative is with log(eta)
        case 'theta'
            A = (M^(5/6))/pi^(2/3)*sqrt((5*eta)/24)*fVec.^(-7/6);
            [dCBydtheta] = dC_dtheta(phi, theta, psi, iota, Det);
            dAeffBydLamba = (A/dL)*dCBydtheta;
        case 'phi'
            A = (M^(5/6))/pi^(2/3)*sqrt((5*eta)/24)*fVec.^(-7/6);
            [dCBydphi] = dC_dphi(phi, theta, psi, iota, Det);
            dAeffBydLamba = (A/dL)*dCBydphi;
        case 'dL'
            A = (M^(5/6))/pi^(2/3)*sqrt((5*eta)/24)*fVec.^(-7/6);
            [C] = CalcC(phi, theta, psi, iota, Det);
            dAeffBydL = (A*C)*(-1/dL^2);
            dAeffBydLamba = dL*dAeffBydL;       % returned derivative is with log(dL)
        case 'psi'
            A = (M^(5/6))/pi^(2/3)*sqrt((5*eta)/24)*fVec.^(-7/6);
            [dCBydpsi] = dC_dpsi(phi, theta, psi, iota, Det);
            dAeffBydLamba = (A/dL)*dCBydpsi;
        case 'iota'
            A = (M^(5/6))/pi^(2/3)*sqrt((5*eta)/24)*fVec.^(-7/6);
            [dCBydiota] = dC_diota(phi, theta, psi, iota, Det);
            dAeffBydLamba = (A/dL)*dCBydiota;
        case 't0'
            dAeffBydLamba = zeros(size(fVec));
        case 'phi0'
            dAeffBydLamba = zeros(size(fVec));
    end

